package com.mzy.basics.test.cloneTwoChangeTwo;

import lombok.Getter;
import lombok.Setter;

/**
 * @author Ives
 * * @date 2022/1/26
 */
@Getter
@Setter
public class Person implements Cloneable{
  public Person(String name, int age, String email, String desc) {
    this.name = name;
    this.age = age;
    this.email = email;
    this.personDesc = new PersonDesc();
    this.personDesc.setDesc(desc);
  }

  // 姓名
    private String name;
    // 年龄
    private int age;
    // 邮件
    private String email;
    // 描述
    private PersonDesc personDesc;

  public void setDesc(String desc) {
    this.personDesc.setDesc(desc);
  }
    /*
     * 重写 clone 方法，需要将权限改成 public ，直接调用父类的 clone 方法就好了
     */
    @Override
    public Object clone() throws CloneNotSupportedException {
      return super.clone();
    }


  @Override
  public String toString() {
    return "Person{" +
            "name='" + name + '\'' +
            ", age=" + age +
            ", email='" + email + '\'' +
            ", personDesc=" + personDesc.getDesc() +
            '}';
  }
}
